Skip to content

Infer template arguments from callable return types - #6715

Open
simPod wants to merge 5 commits into
phpstan:2.3.xfrom
simPod:fix/callable-return-template-inference
Open

simPod wants to merge 5 commits into
phpstan:2.3.xfrom
simPod:fix/callable-return-template-inference

Conversation

@simPod

@simPod simPod commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

With unresolvedTemplateArguments enabled, a generic helper whose callback returns Pair<K, V> can produce Map<mixed, mixed> even when the callback constructs the pair from typed values.

TemplateArgumentObserver::observeLowerBound() skips the entire callable signature to avoid treating contravariant parameters as lower bounds. This also drops constraints from callable returns.

Collect lower bounds from callable return types while leaving parameter positions unchanged. Apply the same change to the Turbo implementation.

@simPod
simPod marked this pull request as ready for review October 9, 2026 10:28
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants